<template>
  <el-dialog
    v-el-drag-dialog
    title="气瓶条码明细"
    :visible.sync="visible"
    width="600px"
  >
    <div v-for="item in dataList" :key="item.id">
      <h3>{{ temp.goodsName }} — {{ formatGdStatus(item.gdStatus) }}</h3>
      <el-tag v-for="it in item.goodsSN1.split(',')" :key="it">{{ it }}</el-tag>
    </div>
  </el-dialog>
</template>

<script>
  import { queryBottleChipDetailList } from '@/api'

  export default {
    name: 'InAndOutStoreDetail',
    data() {
      return {
        type: 1,
        visible: false,
        temp: {},
        dataList: []
      }
    },
    methods: {
      open(temp) {
        this.fetchData(temp)
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
          this.temp = Object.assign(this.temp, temp)
        })
      },
      async fetchData(temp) {
        const res = await queryBottleChipDetailList({
          storeId: temp.storeId,
          goodsId: temp.goodsId,
          specCode: temp.specCode,
          gdStatus: temp.gdStatus
        })
        this.dataList = JSON.parse(res.data.billInfoList)
      },
      formatGdStatus(gdStatus) {
        let str = ''
        if (gdStatus === 1) {
          str = '重瓶'
        } else if (gdStatus === 2) {
          str = '空瓶'
        } else if (gdStatus === 3) {
          str = '回收瓶'
        } else if (gdStatus === 4) {
          str = '故障瓶'
        } else if (gdStatus === 5) {
          str = '已损坏'
        } else {
          str = '正常'
        }
        return str
      }
    }
  }
</script>

<style scoped>

</style>
